package com.vinder.api.util;


import java.util.Random;


public class NumUtil {
    /**
     * 随机生成指定长度的数字
     */
    public static int createCode(int length) {
        //1.实例化随机对象
        Random random = new Random();
        //2.计算起始值
        int n = (int) Math.pow(10, length - 1);
        //3.获取结果
        return n + random.nextInt(9 * n);
    }
}
